﻿using YMJF_Service.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using xrwang.PublicLibrary;


    /// <summary>
    /// 消息类型
    /// </summary>
    public enum MessageType
    {
        /// <summary>
        /// 请求
        /// </summary>
        Request,
        /// <summary>
        /// 响应
        /// </summary>
        Response,
        /// <summary>
        /// 异常
        /// </summary>
        Exception
    }

    /// <summary>
    /// Message：消息
    /// </summary>
    public class MessageBL : message
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="content"></param>
        /// <param name="time"></param>
        public  MessageBL(Guid id, string type, string content, DateTime time)
        {
           
            this.ID = id.ToString();
            this.Content = content;

            this.Type = type;
            this.Time = time;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="type"></param>
        /// <param name="content"></param>
        public MessageBL(string type, string content)
            : this(Guid.NewGuid(), type, content, DateTime.Now)    
        {
           
        }


        /// <summary>
        /// 插入新消息
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns>返回插入是否成功</returns>
        public static bool Insert(message message)
        {
            object obj=message.Insert();
            return obj!=null;
        }
    }
